﻿<template>
    <div style="height:100%;">
        <Row>
            <Col span="24" class="col-margin">
            <!--根据需求删除不不要查询条件-->
             填报年度：
            <Select v-model="searchModel.FillInYear" placeholder="全部" style="width: 200px" @on-change="initReport()">
                <!-- <Option value="">全部</Option> -->
                <Option :value="item.DictValue" v-for="item in yearList" :key="item.DictValue">{{item.DictText}}</Option>
            </Select>
            <!-- <Button icon="ios-search" type="ghost" @click="getPageData()">查询</Button> -->
            <Button icon="ios-download" type="info" @click="ExcelDown()" style="float:right;margin-right:20px" v-show="isCreated&&ReportStatus*1 >1">数据导出</Button>
            <Upload :on-success="handleSuccess" :action="GetPostUrl()" style="float:right;margin-right:20px" v-show="isCreated&&ReportStatus*1 <3">
                <Button type="success" icon="ios-cloud-upload-outline">数据导入</Button>
            </Upload>
            <Button icon="ios-download" type="warning" @click="TmpDown()" style="float:right;margin-right:20px">模板下载</Button>
            </Col>
        </Row>  
        <div v-show="isCreated">      
        <Row>
            <Col span="24" class="col-margin">
            <div id="griddiv" style="overflow-y:auto" v-bind:style="{ height: clientHeight + 'px' }">
                <Form ref="dataModel" :model="DataModel" :rules="ruleValidate" > 
                <table class="gridtable">
                    <caption>
                        <span style="float:left;font-size:20px;color:#050505">{{searchModel.FillInYear}}马铃薯技术推广机构及人员情况表</span>
                        <span style="float:right" v-show="ReportStatus==0">[<a @click="ReasonShow=true">未通过原因</a>]</span>
                        <div style="float:right;margin-right:5px;">当前状态:
                            <span v-if="ReportStatus==0" class="Error">退回重报</span> 
                            <span v-else-if="ReportStatus==1" class="NoReport">未填写</span>
                            <span v-else-if="ReportStatus==2" class="AlreadyReport">已填写</span>
                            <span v-else-if="ReportStatus==3" class="UpReport">已上报</span>
                            <span v-else-if="ReportStatus==4" class="Success">审核通过</span>               
                            <span v-else class="NoReport">未知</span>               
                        </div>
                    </caption>
                    <thead>
                    <tr>
                        <th >名称</th>
                        <th style="width:27em">分类</th>
                        <th >数量</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <th style="text-align:left;">一、马铃薯技术服务机构数（个）</th>
                        <th></th>
                        <th>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.InstituNum"> 
                                <Form-item prop="InstituNum">
                                    <!-- <Input v-model="DataModel.InstituNum" disabled></Input> -->
                                    <Button long>{{DataModel.InstituNum}}</Button>
                                    <td style="display:none">{{DataModel.InstituNum = DataModel.InstituNum_City*1+DataModel.InstituNum_Area*1+DataModel.InstituNum_town*1}}</td>
                                </Form-item>
                            </Poptip>
                        </th>
                    </tr>
                    <tr>
                        <td style="text-align:center;" rowspan="3">其中</td>
                        <td style="padding-left:13em;">州市级</td>                        
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.InstituNum_City"> 
                                <Form-item prop="InstituNum_City" :rules="(isCity)?commonRule:{}">
                                    <Input v-model="DataModel.InstituNum_City" :disabled="!isCity"></Input>
                                </Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">县级</td>                        
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.InstituNum_Area"> 
                                <Form-item prop="InstituNum_Area" :rules="(!isCity)?commonRule:{}">
                                    <Input v-model="DataModel.InstituNum_Area" :disabled="isCity"></Input>
                                </Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">乡镇级</td>                        
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.InstituNum_town"> 
                                <Form-item prop="InstituNum_town" :rules="(!isCity)?commonRule:{}">
                                    <Input v-model="DataModel.InstituNum_town" :disabled="isCity"></Input>
                                </Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align:left;" >一、专业技术人员数量（人）</th>
                        <th></th>
                        <th>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum"> 
                                <Form-item prop="PeopleNum">
                                    <!-- <Input v-model="DataModel.PeopleNum"></Input> -->
                                    <Button long>{{conPeopleNum()}}</Button>
                                </Form-item>
                            </Poptip>
                        </th>
                    </tr>
                     <tr>
                         <td style="text-align:center;" rowspan="2">其中</td>
                        <td style="padding-left:13em;">县乡级人数</td>                        
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_County"> 
                                <Form-item prop="PeopleNum_County" :rules="(!isCity)?commonRule:{}">
                                    <Input v-model="DataModel.PeopleNum_County" :disabled="isCity"></Input>
                                </Form-item>
                            </Poptip>
                        </td>
                    </tr>
                     <tr>
                        <td style="padding-left:13em;">州市级人数</td>                        
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_City"> 
                                <Form-item prop="PeopleNum_City" :rules="(isCity)?commonRule:{}">
                                    <Input v-model="DataModel.PeopleNum_City" :disabled="!isCity"></Input>
                                </Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td rowspan="2" style="text-align:center;">（一）按性别分</td>
                        <td style="padding-left:13em;">男</td>
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_man"> 
                                <Form-item prop="PeopleNum_man">
                                    <Input v-model="DataModel.PeopleNum_man"></Input>
                                </Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">女</td>
                        <td>
                            <Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_woman"> 
                                <Form-item prop="PeopleNum_woman">
                                    <Input v-model="DataModel.PeopleNum_woman"></Input></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;" rowspan="4">（二）按年龄分</td>
                        <td style="padding-left:10em;">其中：30岁以下（含30）</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_age1"> 
                                <Form-item prop="PeopleNum_age1"><Input v-model="DataModel.PeopleNum_age1"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">30-40岁（含40）</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_age2"> 
                                <Form-item prop="PeopleNum_age2"><Input v-model="DataModel.PeopleNum_age2"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">40-50岁（含50）</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_age3"> 
                                <Form-item prop="PeopleNum_age3"><Input v-model="DataModel.PeopleNum_age3"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">50岁以上</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_age4"> 
                                <Form-item prop="PeopleNum_age4"><Input v-model="DataModel.PeopleNum_age4"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;" rowspan="5">（三）按学历层次分</td>
                        <td style="padding-left:10em;">其中：硕士及以上</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_xlss"> 
                                <Form-item prop="PeopleNum_xlss"><Input v-model="DataModel.PeopleNum_xlss"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">本科</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_xlbk"> 
                                <Form-item prop="PeopleNum_xlbk"><Input v-model="DataModel.PeopleNum_xlbk"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">大专</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_xldz"> 
                                <Form-item prop="PeopleNum_xldz"><Input v-model="DataModel.PeopleNum_xldz"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">中专（技校）</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_xlzz"> 
                                <Form-item prop="PeopleNum_xlzz"><Input v-model="DataModel.PeopleNum_xlzz"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">其他</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_xlqt"> 
                                <Form-item prop="PeopleNum_xlqt"><Input v-model="DataModel.PeopleNum_xlqt"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center;" rowspan="5">（四）职称情况</td>
                        <td style="padding-left:10em;">其中：正高级职称</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_zczgj"> 
                                <Form-item prop="PeopleNum_zczgj"><Input v-model="DataModel.PeopleNum_zczgj"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">副高级职称</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_zcfgj"> 
                                <Form-item prop="PeopleNum_zcfgj"><Input v-model="DataModel.PeopleNum_zcfgj"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">中级职称</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_zczj"> 
                                <Form-item prop="PeopleNum_zczj"><Input v-model="DataModel.PeopleNum_zczj"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">初级职称</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_zccj"> 
                                <Form-item prop="PeopleNum_zccj"><Input v-model="DataModel.PeopleNum_zccj"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left:13em;">其他</td>
                        <td><Poptip trigger="focus" title="上年数据" :content="oldDataModel.PeopleNum_zcqt"> 
                                <Form-item prop="PeopleNum_zcqt"><Input v-model="DataModel.PeopleNum_zcqt"/></Form-item>
                            </Poptip>
                        </td>
                    </tr>
                    </tbody>
                </table>
                </Form>
                <div class="divButton">
                    <Button type="primary" @click="save('dataModel')" :disabled="ReportStatus < 3 ? false:true ">保存</Button>
                    <Button type="primary" @click="DataUp()" :disabled="ReportStatus == 2 ? false:true">上报</Button>
                </div>
                <Alert  type="error">
                    填报时间：每年1月10日
                    <p> 填报说明：1.全省范围内从乡（镇）起，逐级全面统计，由县级填报经州（市）审核后上报。</p> 
                    <span slot="desc"></span>
                </Alert>
            </div>           
            </Col>
        </Row>
        </div>
        <div v-show="!isCreated" class="NoCreatedDiv">
            <h1>{{ReportLine}}</h1>
        </div>
        <Modal v-model="ReasonShow" :mask-closable="false" width="500"> 
            <p slot="header" class="title">
                <Icon type="ios-paper" size="20"></Icon>
                <span style="font-size: 20px">未通过原因</span>
            </p>
            <p slot="close">
                <Icon type="close-circled" color="red" size=25></Icon>
            </p>
            <div class="reasonDiv"><Input v-model="Opinion" type="textarea" readonly :autofocus="true" :rows="10"  ></Input></div>
            <p slot="footer"></p>
        </Modal>  
    </div>
</template>
<script>
export default {
    data() {
        const validateData = (rule, value, callback) => {
            var temp = /^[0-9]\d*(\.\d+)?$/;
            if (value||value==0) {
                if (temp.test(value) == false) {
                    callback(new Error('必须是数字！'));
                }
                else {
                    callback();
                }
            } else {
                callback(new Error('不能为空！'));
            }
        };
        return {
            isCreated:false,//是否需要显示报表
            ReportLine:'',//不显示报表时所显示文字
            ReasonShow:false,
            showType: false,//编辑框弹出状态
            yearList: this.GetGroupDict("ReportYear"),
            ReportId: "",
            ReportStatus: "", 
            Opinion:'',
            AreaCode: this.GetlocaStorage("potUserinfo").AreaCode,
            isCity:'',
            commonRule:{ validator: validateData, trigger: 'blur' },
            ruleValidate: {//验证模型
                // ReportId:[{ required: true, message: '报表编号不能为空', trigger: 'blur' }], 
               // InstituNum:{ validator: validateData, trigger: 'blur' }, 
                //InstituNum_City:{ validator: validateData, trigger: 'blur' }, 
                //InstituNum_Area:{ validator: validateData, trigger: 'blur' }, 
                //InstituNum_town:{ validator: validateData, trigger: 'blur' }, 
               // PeopleNum:{ validator: validateData, trigger: 'blur' }, 
               // PeopleNum_County:{ validator: validateData, trigger: 'blur' }, 
               // PeopleNum_City:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_man:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_woman:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_age1:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_age2:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_age3:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_age4:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_xlss:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_xlbk:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_xldz:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_xlzz:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_xlqt:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_zczgj:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_zcfgj:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_zczj:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_zccj:{ validator: validateData, trigger: 'blur' }, 
                PeopleNum_zcqt:{ validator: validateData, trigger: 'blur' }, 
            },
            DataModel: {//编辑模型
                Id: '',
                ReportId:'', 
                InstituNum:'', 
                InstituNum_City:'', 
                InstituNum_Area:'', 
                InstituNum_town:'', 
                PeopleNum:'', 
                PeopleNum_County:'', 
                PeopleNum_City:'', 
                PeopleNum_man:'', 
                PeopleNum_woman:'', 
                PeopleNum_age1:'', 
                PeopleNum_age2:'', 
                PeopleNum_age3:'', 
                PeopleNum_age4:'', 
                PeopleNum_xlss:'', 
                PeopleNum_xlbk:'', 
                PeopleNum_xldz:'', 
                PeopleNum_xlzz:'', 
                PeopleNum_xlqt:'', 
                PeopleNum_zczgj:'', 
                PeopleNum_zcfgj:'', 
                PeopleNum_zczj:'', 
                PeopleNum_zccj:'', 
                PeopleNum_zcqt:'', 
            },
            oldDataModel: {//编辑模型
                Id: '',
                ReportId:'', 
                InstituNum:'', 
                InstituNum_City:'', 
                InstituNum_Area:'', 
                InstituNum_town:'', 
                PeopleNum:'', 
                PeopleNum_County:'', 
                PeopleNum_City:'', 
                PeopleNum_man:'', 
                PeopleNum_woman:'', 
                PeopleNum_age1:'', 
                PeopleNum_age2:'', 
                PeopleNum_age3:'', 
                PeopleNum_age4:'', 
                PeopleNum_xlss:'', 
                PeopleNum_xlbk:'', 
                PeopleNum_xldz:'', 
                PeopleNum_xlzz:'', 
                PeopleNum_xlqt:'', 
                PeopleNum_zczgj:'', 
                PeopleNum_zcfgj:'', 
                PeopleNum_zczj:'', 
                PeopleNum_zccj:'', 
                PeopleNum_zcqt:'', 
            },
            clientHeight: window.innerHeight - 183,//表格默认高度
            //查询模型：根据需求删除不不要查询条件
            searchModel: {     
                ReportCode:'PotPromotion',          
                FillInYear:new Date().getFullYear()+'',
                PageNumber: 1, PageSize: 20
            },
           
        }
    },
    mounted() {
        //table高度计算方法
        const that = this;
        window.onresize = () => {
            return (() => {
                that.clientHeight = window.innerHeight - 180;
            })()
        };
    },
    methods: {        
        getPageData() {
            var self = this;
            this.$http.get('PotPromotion', {params:{AreaCode:this.AreaCode,FillInYear:this.searchModel.FillInYear}}).then(function (res) {
                if (res.data.status === 1) {
                    self.DataModel = res.data.model.DataModel;
                    if(res.data.model.OldDataModel)
                    self.oldDataModel = res.data.model.OldDataModel;
                    self.ReportStatus = res.data.model.ReportStatus; 
                    self.ReportId = res.data.model.ReportId; 
                    self.Opinion = res.data.model.Opinion;  
                    self.isCreated = true;
                }
                else {
                    self.isCreated = false;
                    self.ReportLine = '报表未生成！';
                    self.ReportStatus = null;
                    self.$Modal.error({ title: '提示信息', content: res.data.message });
                }
            });
        },        
        save(modelname) {
            var self = this;
            this.$refs[modelname].validate((valid) => {
                if (valid) {
                    this.$http.put('PotPromotion', this.DataModel).then(
                        function (res) {
                            if (res.data.status == 1) {
                                self.getPageData();                               
                                self.$Notice.success({ title: '保存成功！', desc: false });
                                }
                            else {
                                self.$Modal.warning({ title: "提示信息", content: res.data.message });
                            }
                    });
                    
                }
                else{
                    self.$Modal.error({ title: "提示信息", content: '无法保存，请检查是否有未填项！' });
                }
            });
        },
        checkData(){
            var self = this;
            if((this.convertNum(self.DataModel.InstituNum_City)+this.convertNum(self.DataModel.InstituNum_Area)+ this.convertNum(self.DataModel.InstituNum_town)) != this.convertNum(self.DataModel.InstituNum)){
                self.$Modal.error({ title: "提示信息", content: "马铃薯技术服务机构数应等于其中子项加起来的和!" });      
                return false;
            }else if((this.convertNum(self.DataModel.PeopleNum_County)+this.convertNum(self.DataModel.PeopleNum_City)) != this.convertNum(self.DataModel.PeopleNum)){
                self.$Modal.error({ title: "提示信息", content: "专业技术人员数量应等于其中子项加起来的和!" });                    
                return false;
            }else if((this.convertNum(self.DataModel.PeopleNum_man)+this.convertNum(self.DataModel.PeopleNum_woman)) != this.convertNum(self.DataModel.PeopleNum)){
                self.$Modal.error({ title: "提示信息", content: "专业技术人员数量应等于按性别分加起来的和!" });                       
                return false;
            }else if((this.convertNum(self.DataModel.PeopleNum_age1)+this.convertNum(self.DataModel.PeopleNum_age2)+this.convertNum(self.DataModel.PeopleNum_age3)+this.convertNum(self.DataModel.PeopleNum_age4))!= this.convertNum(self.DataModel.PeopleNum)){
                self.$Modal.error({ title: "提示信息", content: "专业技术人员数量应等于按年龄分加起来的和!" });                     
                return false;
            }
            else if((this.convertNum(self.DataModel.PeopleNum_xlss)+this.convertNum(self.DataModel.PeopleNum_xlbk)+this.convertNum(self.DataModel.PeopleNum_xldz)+this.convertNum(self.DataModel.PeopleNum_xlzz)+this.convertNum(self.DataModel.PeopleNum_xlqt)) != this.convertNum(self.DataModel.PeopleNum)){
                self.$Modal.error({ title: "提示信息", content: "专业技术人员数量应等于按学历层次分加起来的和!" });                      
                return false;
            }else if((this.convertNum(self.DataModel.PeopleNum_zczgj)+this.convertNum(self.DataModel.PeopleNum_zcfgj)+this.convertNum(self.DataModel.PeopleNum_zczj)+this.convertNum(self.DataModel.PeopleNum_zccj)+this.convertNum(self.DataModel.PeopleNum_zcqt)) != this.convertNum(self.DataModel.PeopleNum)){
                self.$Modal.error({ title: "提示信息", content: "专业技术人员数量应等于按职称情况分加起来的和!" });                     
                return false;
            }
            else {
                return true;
            }
        },
        convertNum: function (num) { //小数点处理
            if (isNaN(num)||num == null||num=='') {
                return 0;
            }
            return num*1;
        },
        //数据上报
        DataUp() {
            var self = this;
            let model = new Object();
            model.Id = this.ReportId;
            model.Status = 3;
            model.Opinion = '';
            if(this.checkData()){
                self.$Modal.confirm({
                    title: '提示信息',
                    content: '<p>数据上报后，不能再更改，是否继续上报？</p>',
                    onOk: () => {
                        this.$http.post("Report/PostUpStatus", model).then(
                            function (res) {
                                if (res.data.status == 1) {                                
                                    self.$Notice.success({ title: '数据上报成功！', desc: false });
                                    self.getPageData();
                                }
                                else {
                                    self.$Modal.error({ title: "提示信息", content: "数据上报失败!" });
                                }
                            }
                        );
                    }
                });
            }            
        },       
        conPeopleNum(){
            if((this.DataModel.PeopleNum_County !=null&&this.DataModel.PeopleNum_County!='')||(this.DataModel.PeopleNum_City !=null&&this.DataModel.PeopleNum_City!='')){
                this.DataModel.PeopleNum = this.DataModel.PeopleNum_County*1 + this.DataModel.PeopleNum_City*1;
            }
            else if((this.DataModel.PeopleNum_woman !=null&&this.DataModel.PeopleNum_woman!='')||(this.DataModel.PeopleNum_man !=null&&this.DataModel.PeopleNum_man!='')){
                this.DataModel.PeopleNum = this.DataModel.PeopleNum_woman*1 + this.DataModel.PeopleNum_man*1;
            }
            else if((this.DataModel.PeopleNum_age1 !=null&&this.DataModel.PeopleNum_age1!='')||(this.DataModel.PeopleNum_age2 !=null&&this.DataModel.PeopleNum_age2!='')||(this.DataModel.PeopleNum_age3 !=null&&this.DataModel.PeopleNum_age3!='')||(this.DataModel.PeopleNum_age4 !=null&&this.DataModel.PeopleNum_age4!='')){
                this.DataModel.PeopleNum = this.DataModel.PeopleNum_age1*1 + this.DataModel.PeopleNum_age2*1+this.DataModel.PeopleNum_age3*1 + this.DataModel.PeopleNum_age4*1;
            }
            else if((this.DataModel.PeopleNum_xlss !=null&&this.DataModel.PeopleNum_xlss!='')||(this.DataModel.PeopleNum_xlbk !=null&&this.DataModel.PeopleNum_xlbk!='')||(this.DataModel.PeopleNum_xldz !=null&&this.DataModel.PeopleNum_xldz!='')||
            (this.DataModel.PeopleNum_xlzz !=null&&this.DataModel.PeopleNum_xlzz!='')||(this.DataModel.PeopleNum_xlqt !=null&&this.DataModel.PeopleNum_xlqt!='')){
                this.DataModel.PeopleNum = this.DataModel.PeopleNum_xlss*1 + this.DataModel.PeopleNum_xlbk*1+this.DataModel.PeopleNum_xldz*1 + this.DataModel.PeopleNum_xlzz*1+this.DataModel.PeopleNum_xlqt*1;
            }
            else if((this.DataModel.PeopleNum_zczgj !=null&&this.DataModel.PeopleNum_zczgj!='')||(this.DataModel.PeopleNum_zcfgj !=null&&this.DataModel.PeopleNum_zcfgj!='')||(this.DataModel.PeopleNum_zczj !=null&&this.DataModel.PeopleNum_zczj!='')||
            (this.DataModel.PeopleNum_zccj !=null&&this.DataModel.PeopleNum_zccj!='')||(this.DataModel.PeopleNum_zcqt !=null&&this.DataModel.PeopleNum_zcqt!='')){
                this.DataModel.PeopleNum = this.DataModel.PeopleNum_zczgj*1 + this.DataModel.PeopleNum_zcfgj*1+this.DataModel.PeopleNum_zczj*1 + this.DataModel.PeopleNum_zccj*1+this.DataModel.PeopleNum_zcqt*1;
            }
            else{
                this.DataModel.PeopleNum = 0;
            }
            return this.DataModel.PeopleNum;
        },
        //模板下载
        TmpDown:function(){
            window.open(this.$http.defaults.baseURL + "Report/GetTemplateData?ReportCode=" + this.searchModel.ReportCode);
        },
         //导入
        GetPostUrl() {
            var url = this.$http.defaults.baseURL + "PotPromotion/PostImportData?ReportId=" + this.ReportId + "&&AreaCode=" + this.AreaCode;
            return url;
        },
        //导入成功反馈事件
        handleSuccess(res, file) {
            var self = this;
            self.getPageData();
            if(res.status == -1){
                self.$Modal.warning({
                    title: "提示信息",
                    content: "导入失败，"+res.message
                });
            }else{
                self.$Notice.success({
                    title: '数据导入成功！',
                    desc: false
                });
            }            
        },
        //导出
        ExcelDown: function () {           
            window.open(this.$http.defaults.baseURL + "PotPromotion/GetExcelData?FillInYear=" + this.searchModel.FillInYear + "&&AreaCode=" + this.AreaCode);
        },
        initReport(){
            var today = new Date();
            let currentYear = today.getFullYear();
            let currentMonth = today.getMonth() + 1;
            if(this.searchModel.FillInYear*1 == currentYear &&currentMonth==12){
               this.getPageData();
            }
            else if(this.searchModel.FillInYear*1 == currentYear-1 && currentMonth >= 1 && currentMonth <= 5){
                this.getPageData();
            }
            else if(this.searchModel.FillInYear < currentYear){
                this.getPageData();
            }
            else {
                this.isCreated = false;
                this.ReportLine = '不在填报时间内！';
            }
        }
        
    },
    //创建Vue页面方法
    created: function () {
        //创业Vue前调用获取this.datas: {},//table数据对象
        this.initReport();
        let areaCode = this.GetlocaStorage("potUserinfo").AreaCode;
        if(areaCode.substr(4, 8) == "00000000"){
            this.isCity = true;
        }else{
            this.isCity = false;
        }     
    },
    watch: {
        //需要监听的在此处新增监听对象
    }
}
</script>
